/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package documenteditor.entidade.model;

import java.io.Serializable;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import org.hibernate.annotations.ForeignKey;

/**
 *
 * @author gleidson.moura
 */
@Embeddable
public class ServicoVendaPK implements Serializable {

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @ForeignKey(name="PK_SERVICO_VENDA_VENDA")
    private Venda venda;

    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @ForeignKey(name="PK_SERVICO_VENDA_SERVICO")
    private Servico servico;

    public Servico getServico() {
        return servico;
    }

    public void setServico(Servico servico) {
        this.servico = servico;
    }

    public Venda getVenda() {
        return venda;
    }

    public void setVenda(Venda venda) {
        this.venda = venda;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ServicoVendaPK other = (ServicoVendaPK) obj;
        if (this.venda != other.venda && (this.venda == null || !this.venda.equals(other.venda))) {
            return false;
        }
        if (this.servico != other.servico && (this.servico == null || !this.servico.equals(other.servico))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 53 * hash + (this.venda != null ? this.venda.hashCode() : 0);
        hash = 53 * hash + (this.servico != null ? this.servico.hashCode() : 0);
        return hash;
    }
}
